<?php
/**
 * Created by PhpStorm.
 * User: Ray
 * Date: 2019/9/20 0020
 * Time: 23:28
 */

namespace app\Models;


use core\lib\Model;

class PostModel extends Model
{
    public $table = 'posts';
    public function posts()
    {
        return $this->select($this->table, '*');
    }

    public function getOne($id)
    {
//        array条件
        return $this->get($this->table, '*',array(
            'id' => $id
        ));
    }

    public function updateOne($id, $data)
    {
//        $data = array(
//            'name'=> 'new name'
//        )
        return $this->update($this->table, $data, array(
            'id' => id
        ));
    }

    public function deleteOne($id)
    {
        return parent::delete($this->table, array(
            'id' => $id
        ));
    }
}